package ch.ffhs.bscinf2009.organizeanything;

import android.content.Context;
import ch.ffhs.bscinf2009.organizeanything.data.DatabaseService;
import ch.ffhs.bscinf2009.organizeanything.data.DatabaseServiceMock;

/**
 * @author lir
 * The environment proivides easy access to the database using a singleton pattern.
 */
public class Environment {
	
	private static Environment environment;
	private DatabaseServiceMock dbService;
	
	private Environment(){
		
	}
	
	/** Retrieve the singleton instance of the environment
	 * @return the current Environment
	 */
	public static Environment getInstance(){
		if(environment == null){
			environment = new Environment();
		}
		return environment;
	}
	
	/**
	 * Get access to the database service.
	 * @param context the context in which the database service should be running
	 * @return the database service itself
	 */
	public DatabaseService getDB(Context context){
		if(dbService == null){
			// it is possible to Mock the service here to generate some test data.
			dbService = new DatabaseServiceMock(context);
			//dbService.generateTestData();
		}
		return dbService;
	}

}
